import Vue from 'vue'
import VueRouter from 'vue-router'
import { setPV } from './routerUtils'

Vue.use(VueRouter)

import layoutChildern from './layoutChildern';

const routes = [
    {
        path: '/',
        redirect: '/layout',
    },
    {
        path: '/layout',
        name: 'layout',
        redirect: '/home',
        component: () => import('@/views/Layout/index'),
        children: layoutChildern,
    },
    {
        path: '/writeBlog',
        name: 'writeBlog',
        component: () => import('@/views/WriteBlog/index'),
        meta: {
            bloggerBtn: 'hidden',
        }
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/Login/index'),
        meta: {
            bloggerBtn: 'hidden',
        }
    }
]

const router = new VueRouter({
    routes
})



router.beforeEach((to, from, next) => {

    // 统计pv
    setPV(to, from)
    next()
})

export default router
